package JmmAndMultiThread.MultiThreads;
public class DifferBetweenRunAndStart {

    //test
    public static void main(String[] args) {
        //继承Thread
        MyThread1 myThread1 = new MyThread1();
        MyThread2 myThread2 = new MyThread2();
        MyThread3 myThread3 = new MyThread3();
        MyThread4 myThread4 = new MyThread4();
        //实现Runnable
        Thread thread5=new Thread(new Thread5());
//        Thread thread5 = new Thread(()->{
//            System.out.println(Thread.currentThread().getName()+" started!");
//        },"KAKA");
        myThread1.start();
        myThread2.start();
        myThread3.start();
        myThread4.start();
        thread5.start();
        //run相当于主线程的一个方法，当前运行线程仍是主线程；start才是真正开启了一个新线程
//        myThread1.run();
//        myThread2.run();
//        myThread3.run();
//        myThread4.run();

    }

}
class MyThread1 extends Thread{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+" started!");
    }
}
class MyThread2 extends Thread{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+" started!");
    }
}
class MyThread3 extends Thread{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+" started!");
    }
}
class MyThread4 extends Thread{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+" started!");
    }
}
class Thread5 implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+" started!");
    }
}